home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Text Reader < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  1.1 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Text Reader
  2. Sent:        6/11/96 1:07 PM
  3. Received:    6/11/96 1:21 PM
  4. From:        Mary Boetcher, mary_boetcher@quickmail.apple.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8.         Reply to:   RE>>Text Reader
  9.  
  10. >>If I want to copy from a text reader to a string, would the following loop
  11. >>be both OK and efficient?
  12. I think the following code would be slightly more efficient, since there are fewer function calls. It relies on the fact that the text reader returns a null character when it reaches the end of its text:
  13.  
  14. FW_CString string;
  15. while (true)
  16. {
  17.         FW_LChar ch = reader->GetCharacterAndAdvance();
  18.         if (ch == 0) break;  // end of text
  19.         string.Append(ch);
  20.         if (ch == chTab || ch == chReturn)
  21.                 break;
  22. }
  23.  
  24. >>Also, why do you allocate the reader with the FW_NEW operator instead of
  25. >>allocating it on the stack?
  26. I copied that code from my test part, which keeps the reader in a data member:
  27.    FW_CStringReader*  fReader;
  28.  
  29. Mary Boetcher
  30. ODF Person
  31.